<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>用户管理界面</title>

    <meta charset="utf-8"/>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	
	<link rel="stylesheet" href="gold/css/bootstrap.min.css">
	<script src="gold/js/jquery.js"></script>
	<script src="gold/js/bootstrap.min.js"></script>
	<style type="text/css">
		#container {
			margin-top: -20px;
			margin-left: 10px;
		}
		td {
			vertical-align: middle !important;
		}
		.zhong{
			margin:auto;
		}
	</style>
	<script type="text/javascript">
  		$(function(){
  			$("#all").click(function(){
  				var choose = $("#all").prop("checked");
  				if(choose){
	  				$("input[name='opt']").prop("checked",true);
  				}else{
	  				$("input[name='opt']").prop("checked",false);
  				}
  			});
  		});
  		function canUse(){
  			var arr = [];
  			$("input[name='opt']").each(function(){
  				var choose=$(this).prop("checked");
  				if(choose){
  					arr.push($(this).val());
  				}
  			});
  			location.href = "updateUserStatusIdByUserId.do?arr="+arr+"&status=1";
  		}
  		function stopUse(){
  			var arr = [];
  			$("input[name='opt']").each(function(){
  				var choose=$(this).prop("checked");
  				if(choose){
  					arr.push($(this).val());
  				}
  			});
  			location.href = "updateUserStatusIdByUserId.do?arr="+arr+"&status=2";
  		}
  	</script>

  </head>
  
  <body>
  	<div id="container"  >
		<div class="page-header">
			<h2>用户列表</h2>
		</div>
		<form action="getUserByLikeAndPage.do" method="post">
			<div class="row">
				<div class="col-xs-6 col-sm-3">
					<div class="row">
						<div class="col-xs-8 col-sm-3">
							<span class="btn btn-default">用户名</span>
						</div>
						<div class="col-xs-3 col-sm-8">
							<input type="text" class="form-control" name="userName"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6 col-sm-2">
					<div class="row">
						<div class="col-xs-8 col-sm-4">
							<span class="btn btn-default">手机号码</span>
						</div>
						<div class="col-xs-3 col-sm-8">
							<input type="text" class="form-control" name="userPhone"/>
						</div>
					</div>
				</div>
				<div class="col-xs-6 col-sm-4">
					<input type="submit" class="btn btn-primary"  value="查询" />
				</div>
			</div>
		</form>
		<div class="row">&nbsp;</div>
		
		<div class="row">
			<div class="col-xs-6 col-sm-4">
				<a class="btn btn-success" onclick="canUse()"> 
					<span class="glyphicon glyphicon-ok-sign"></span>恢复使用
				</a>
				<a class="btn btn-danger" onclick="stopUse()"> 
					<span class="glyphicon glyphicon-trash"></span>禁止使用
				</a>
			</div>
		</div>
		<div class="row">&nbsp;</div>
		
		<div class="row">
			<div class="col-xs-6 col-sm-11">
				<div class="table-responsive"
					style="vertical-align: middle;text-align: center;">
					<table id="searchTable"
						class="table table-bordered table-hover table-condensed  ">
						<tr>
							<td><input type="checkbox" id="all" value="全选"/> 全选</td>
							<td>ID</td>
							<td>用户名</td>
							<td>手机账号</td>
							<td>状态</td>
							<td>创建时间</td>
						</tr>
						<c:forEach var="user" items="${userList}">
							<tr>
								<td><input type='checkbox' name="opt" value="${user.userId}" class="opt"/></td>
								<td>${user.userId }</td>
								<td>${user.userName }</td>
								<td>${user.userPhone }</td>
								<td>${user.userStatus }</td>
								<td>${user.userCreateTime }</td>
							</tr>
						</c:forEach>
					</table>
				</div>
			</div>
		</div>
		<div class="row zhong">
			<a class="btn btn-primary" href="getAllUserByPage.do?nowPageString=${nowPage-1 }">上一页</a>
			<a class="btn btn-primary" href="getAllUserByPage.do?nowPageString=${nowPage+1 }">下一页</a>
		</div>
	</div>
  </body>
  
</html>
